package de.distmlp.preprocessing.parser;

import java.util.ArrayList;
import java.util.List;

import de.distmlp.preprocessing.data.MLDataEntry;

public class MonkParser implements IParser {
	private final int nbInputUnits = 6, nbOutputUnits = 1;

	@Override
	public List<MLDataEntry> parse(final String input) {
		final List<MLDataEntry> list = new ArrayList<MLDataEntry>();
		final MLDataEntry trainingsData = new MLDataEntry(this.nbInputUnits, this.nbOutputUnits);

		final String[] split = input.split(" ");
		if (split.length != 9) {
			System.err.println("Wrong input line! Contains " + split.length + " values instead of 9.");
			return null;
		}

		trainingsData.addOutput(0, Double.parseDouble(split[1]));
		trainingsData.addInput(0, Double.parseDouble(split[2]));
		trainingsData.addInput(1, Double.parseDouble(split[3]));
		trainingsData.addInput(2, Double.parseDouble(split[4]));
		trainingsData.addInput(3, Double.parseDouble(split[5]));
		trainingsData.addInput(4, Double.parseDouble(split[6]));
		trainingsData.addInput(5, Double.parseDouble(split[7]));

		list.add(trainingsData);

		return list;
	}

}
